<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="http://www.google.com/jsapi">

        </script>
        <script>
            google.load("gdata", "1.x");
            google.setOnLoadCallback(initFunc);
            var contactsService;

            function setupContactsService() {
                contactsService = new google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0');
            }

            function logMeIn() {
                var scope = 'https://www.google.com/m8/feeds';
                var token = google.accounts.user.checkLogin(scope);
            }

            function initFunc() {
                setupContactsService();
                logMeIn();
                getMyContacts();
            }
            function getMyContacts() {
                var contactsFeedUri = 'https://www.google.com/m8/feeds/contacts/default/full';
                var query = new google.gdata.contacts.ContactQuery(contactsFeedUri);

                // Set the maximum of the result set to be 5
                query.setMaxResults(5);

                contactsService.getContactFeed(query, handleContactsFeed, handleError);
            }

            var handleContactsFeed = function(result) {
                var entries = result.feed.entry;

                for (var i = 0; i < entries.length; i++) {
                    var contactEntry = entries[i];
                    var emailAddresses = contactEntry.getEmailAddresses();

                    for (var j = 0; j < emailAddresses.length; j++) {
                        var emailAddress = emailAddresses[j].getAddress();
                        alert('email = ' + emailAddress);
                    }
                }
            }
            function handleError(e) {
                alert(e.cause ? e.cause.statusText : e.message);
            }
        </script>

    </head>
    <body>
        <script>
        </script>
    </body>
</html>
